﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using SAKS.Models;
using NHibernate;

namespace SAKS.Services.Query
{
    public class PagedProDocInfoSearch : PagedQueryOverBase<DocumentInfo>
    {
        public PagedProDocInfoSearch(ISession session) : base(session) { }
        public Guid ProjectId { get; set; }
        protected override IQueryOver<DocumentInfo, DocumentInfo> GetQuery()
        {
            var query = Session.QueryOver<DocumentInfo>();
            if (ProjectId == default(Guid))
                throw new ArgumentException("ProjectId is null");
            query = query.Where(p => p.ProjectId == ProjectId);
            query = query.OrderBy(p => p.CreatedDate).Asc;
            return query;
        }
    }
}
